/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Xpath;

import java.io.FileReader;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.xml.sax.InputSource;

/**
 *
 * @author THIEUQUANG
 */
public class GetSeriesId {

    public static void main(String[] args) throws Exception {
        XPathFactory factory = XPathFactory.newInstance();
        XPath xPath = factory.newXPath();

        Double result = (Double) xPath.evaluate("/bookstore/book/@category", new InputSource(new FileReader(
                "books.xml")), XPathConstants.NUMBER);
        System.out.println(result.intValue());
    }
}
